extends ./widget.pug

block input
  .input-group
    // ignore invalid values, let the validation handle it
    - var name;
    if !value || !value.name
      - value = null
    else
      - name = value.name()

    // different behavior for different types of inputs
    if type === 'file' || type === 'image'
      +input(title, type, id, name)(placeholder='Choose an item...', readonly=true)

    else if type === 'directory'
      +input(title, type, id, name)(placeholder='Choose a folder...', readonly=true)

    else if type === 'new-file'
      +input(title, type, id, fileName)(placeholder='Choose an item...', readonly=true)

    else if type === 'new-folder'
      +input(title, type, id, fileName)(placeholder='Choose a folder...', readonly=true)

    span.input-group-btn
      button.btn.btn-default.g-select-file-button(type='button')
        i.icon-folder-open
